//删除个人产量
var util = require('../../tools/util')
var sql = require('../../tools/mysqlCURD')
const { message: { checkSignature } } = require('../../qcloud')
async function post(ctx, next) {
    // 检查签名，确认是微信发出的请求
    const { signature, timestamp, nonce } = ctx.query
    if (!checkSignature(signature, timestamp, nonce)) ctx.body = 'ERR_WHEN_CHECK_SIGNATURE'

    /**
     * 解析微信发送过来的请求体
     * 可查看微信文档：https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/receive.html#接收消息和事件
     */
    var openId=ctx.state.$wxInfo.userinfo.openId;
    const data = util.DateFormat(new Date(),"yyyyMMddhhmmssS").toString().substring(0,8);
    if(openId){
        const  sqlq="DELETE FROM chanliangTable WHERE id LIKE '"+data.trim()+"%' AND userId='"+openId+"'";
        ctx.body= await sql.delete(sqlq)
        ctx.response.status = 200
    }else {
        ctx.state.code = -1
        ctx.body="openid"
    }

}
module.exports = {
    post
}